package com.liu.controller;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//注意：这里我们先导入Controller
public class HelloController implements Controller {
    public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
//      ModeAndView 模型和视图
        ModelAndView modelAndView = new ModelAndView();
//        封装对象,放在ModeAndView中 Mode  类似与web的servlet里的session
        modelAndView.addObject("msg","HelloSpringMVC");
//        封装要跳转的视图,放在ModeAndView中
        modelAndView.setViewName("hello");//因为spingmvc-servlet中配置的视图解析器所以这里可以直接写名字
        return modelAndView;
    }
}
